package com.example.demo.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.index.Indexed;

import java.time.LocalDateTime;

@Document(collection = "questions")
public class Question {
    @Id
    private String id;
    
    @Indexed
    @Field("user_id")
    private Long userId;
    
    private String username;
    
    @Field("question_text")
    private String questionText;
    
    @Field("answer_text")
    private String answerText;
    
    @Field("created_at")
    private LocalDateTime createdAt;

    public Question() {
        this.createdAt = LocalDateTime.now();
    }

    public Question(Long userId, String username, String questionText, String answerText) {
        this.userId = userId;
        this.username = username;
        this.questionText = questionText;
        this.answerText = answerText;
        this.createdAt = LocalDateTime.now();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getQuestionText() {
        return questionText;
    }

    public void setQuestionText(String questionText) {
        this.questionText = questionText;
    }

    public String getAnswerText() {
        return answerText;
    }

    public void setAnswerText(String answerText) {
        this.answerText = answerText;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
}
